package com.rory.controller.back.form;

import com.rory.controller.BaseController;
import com.rory.controller.interceptor.Login;
import com.rory.service.serviceInterface.IndexService;
import com.rory.util.IpMacUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * File: indexCntroller.
 * Created by Rory on 2016/11/15.
 */
@Controller
public class IndexCntroller extends BaseController {

    /**
     * 进入初始页面
     * @param model
     * @return
     */
    @RequestMapping("/")
    public String toBack(Model model) {
        if(getSession().getAttribute("user") != null){
            return "redirect:/ to-mian";
        }
        return "back/login";
    }

    /**
     * 默认第一个页面
     * @return
     */
    @RequestMapping("/index")
    @Login
    public String toIndex(){
        return "back/index";
    }

    /**
     * 注销
     * @return
     */
    @RequestMapping("login-out")
    public String loginOut(){
        getSession().invalidate();
        return "back/login";
    }
}
